<template>
	<view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
			var that = this;
			uni.login({
				provider: 'univerify',
				success(res) { // 登录成功
					console.log(res.authResult); // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
					res.authResult.accessToken = res.authResult.access_token
					return that.$request({
						method: 'POST',
						url: '后台做具体逻辑的接口',
						data: res.authResult
					}).then(res => {
						uni.closeAuthView() //成功关闭授权页面
						console.log('登录成功', res)
						if (res.code) return
						that.$store.commit('setToken', res.data)
						that.$util.msg('登录成功')
						setTimeout(() => {
							uni.redirectTo({
								url: '登陆成功跳转的目标页面'
							})
						}, 500)
					})
				},
				fail(res) { // 登录失败
					console.log(res.errCode)
					console.log(res.errMsg)
				}
			})

			
			
		},
		methods: {
			
		}
	}
</script>

<style>

</style>
